#ifndef __LDX_CUBE_SCENENODE_H_INCLUDE__
#define __LDX_CUBE_SCENENODE_H_INCLUDE__
#include "LDXConfig.h"
#include "ISceneNode.h"
#include "SMaterial.h"
#include "DCBufferDefines.h"
#include "SDeviceMap.h"

namespace ldx
{
	namespace render
	{
		class CProgramVPS;
		class CRenderDriverD3D11;
		class CBufferObject;
	}
	namespace scene
	{
		class CLightsManager;
		class IAnimatedMesh;
		class CCubeSceneNode :public ISceneNode
		{
		public:

			//! Constructor
			CCubeSceneNode(ISceneNode* parent, CSceneManager* mgr, int id = -1,
				const mt::vec3f& position = mt::vec3f(0, 0, 0),
				const mt::vec3f& rotation = mt::vec3f(0, 0, 0),
				const mt::vec3f& scale = mt::vec3f(1.0f, 1.0f, 1.0f));

			~CCubeSceneNode();

			virtual void OnRegisterSceneNode();

			//! Renders the node.
			virtual void render();

			virtual void update(float deltaTime);

			virtual uint getMaterialCount() const
			{
				return 1;
			}


			virtual render::SMaterial& getMaterial(uint num);

			//! Set the new material for one scene node
			// If custom the program,material.ProgramID should be set.
			virtual void setMaterial(render::SMaterial material);

			virtual void setTexture(std::string filename, int index = 0);


		private:

			//! Init local buffers.
			void initLocalBuffers();

			//! Update the buffers such as material buffer and model buffer.
			void updateLocalBuffers();
			
			//! Delete the buffers.
			void deleteLocalBuffers();

			//! Bind local buffers with program.
			void bindLocalBuffers();

			SDeviceMap DM;
			

			render::SMaterial Material;
			CLightsManager* LightsMgr;

			render::CRenderDriverD3D11* Driver;
			render::CProgramVPS* Program;
			std::string ProgramName;
			std::string CubeName;
			IAnimatedMesh* AnimatedMesh;

			render::CBufferMaterial BufferMaterial;
			render::CBufferModel BufferModel;
			render::CBufferModel BufferTransposInverseModel;

			render::CBufferObject* BufferMaterialObj;
			render::CBufferObject* BufferModelObj;
			render::CBufferObject* BufferTransposInverseModelObj;
		};
	}
}

#endif//! __LDX_CUBE_SCENENODE_H_INCLUDE__